<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>添加库存申请单</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/layui/css/layui.css" />
<link rel="stylesheet" href="/static/ui/css/ui.css" />
</head>
<body>
<form class="layui-form" action="" lay-filter="editform">
    <div class="mainBox">
        <div class="main-container">
            <div class="main-container">
            <div class="layui-form-item">
                <label class="layui-form-label">申请人</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required|len" autocomplete="off" min="1" placeholder="请输入申请人用户名" class="layui-input">
                </div>
            </div>
			<div class="layui-form-item">
			    <label class="layui-form-label">入库单</label>
			    <div class="layui-input-block">
			        <input type="text" name="in_id" lay-verify="required|len" autocomplete="off" min="1" placeholder="请输入入库单ID号" class="layui-input">
			    </div>
			</div>

            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="stock_apply-save">
                <i class="layui-icon layui-icon-ok"></i>
                下一步
            </button>
        </div>
    </div>
</form>
<script src="../config.js"></script>
<script src="/static/layui/layui.js"></script>
<script src="/static/ui/ui.js"></script>
<script>
    layui.use(['form','layer','tree'], function () {
        let form = layui.form
            , layer = layui.layer
			, $ = layui.$
            , req = _req();
        form.verify({
            len : (val, item) => {
                let min = item.getAttribute("min")
                if(val.length < min) {
                    return '长度不能小于' + min;
                }
            }
        })

        //监听提交
        form.on('submit(stock_apply-save)', function (data) {
			data = data.field;
            let postUrl = 'stock_apply/check';
			_post(layui, postUrl, data, res => {
				//console.log(res)
				//parent.layui.table.reload("stock_apply-table");
				//parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
				layer.open({
					type: 2,
					title: '添加申请',
					shade: 0.1,
					offset: 'rt',
					area: ['80%', '100%'],
					anim: 1,
					maxmin: true,
					content: './edit.html?user_id=' + res.user_id + "&in_id=" + res.id
				});

			})

            return false;
        });

    });
</script>

</body>
</html>